package com.ruoyi.project.download;

import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Path;

/**
 * Interface for read bytes and write it to {@link OutputStream}.
 *
 * @author zw
 */
public interface FileBytesCopier {

  /**
   * Write the bytes of path with specified range to {@code ostream}.
   *
   * @param ostream the instance of {@link OutputStream} will write bytes to
   * @param path the path string of file
   * @param range the bytes range to be send
   * @throws IOException if an I/O error occurs
   * @throws IllegalArgumentException if the path is null or empty
   */
  void copyRange(OutputStream ostream, String path, Range range)
      throws IOException, IllegalArgumentException;

  /**
   * Write the bytes of path with specified range to {@code ostream}.
   *
   * @param ostream the instance of {@link OutputStream} will write bytes to
   * @param path the path string of file
   * @param range the bytes range to be send
   * @throws IOException if an I/O error occurs
   * @throws IllegalArgumentException if the path is null or empty
   */
  void copyRange(OutputStream ostream, Path path, Range range)
      throws IOException, IllegalArgumentException;

}
